#include <iostream>
#include "scheduler.h"
#include "demo08.h"
#include "fiber.h"

void test_fiber() {
    static int s_count = 5;
    std::cout << "test in fiber s_count=" << s_count <<std::endl;

    sleep(1);
    if(--s_count >= 0) {
        Scheduler::GetThis()->schedule(&test_fiber, sylar::GetThreadId());
    }
}

int main(int argc, char** argv) {
    std::cout << "main" <<std::endl;
    Scheduler sc(3, false, "test");
    sc.start();
    sleep(2);
    std::cout << "schedule" << std::endl;
    sc.schedule(&test_fiber);
    sc.stop();
    std::cout << "over" << std::endl;
    return 0;
}

